<?php
class SelectList
{
    protected $conn;
 
        public function __construct()
        {
            $this->DbConnect();
        }
 
        protected function DbConnect()
        {
            include "db_config.php";
            $this->conn = mysql_connect($host,$user,$password) OR die("Unable to connect to the database");
            mysql_select_db($db,$this->conn) OR die("can not select the database $db");
            return TRUE;
        }
		
		public function GetGroupsByAssignmentKey()
        {
		
            $sql = "CALL GetGroupsAssignmentsKey('$_POST[id]')";
		//$_POST[studentKey]
            $res = mysql_query($sql,$this->conn);
            $assignments = '<option value="0">Select Assignment</option>';
            while($row = mysql_fetch_array($res))
            {
                $assignments.= '<option value="' . $row['AssignmentKey'] . '">' . $row['Name'] . '</option>';
            }
            return $assignments;
        }
 
        public function GetAssignments()
        {
		
            $sql = "CALL GetAssignmentsByLecturerKey('0')";
		//$_POST[studentKey]
            $res = mysql_query($sql,$this->conn);
            $assignments = '<option value="0">Select Assignments</option>';
            while($row = mysql_fetch_array($res))
            {
                $groups.= '<option value="' . $row['AssignmentKey'] . '">' . $row['Name'] . '</option>';
            }
            return $assignments;
        }
		
		public function GetStudentsByGroupId()
		{
		    //$sql = "ALL GetStudentsByGroupKey('$_POST[id]')";
			$sql = "CALL GetStudentsByGroupKey('$_POST[id]')";
            $res = mysql_query($sql,$this->conn);
			$students = '<tbody id="bdyStudents">';
            //$students .= "<tr><td>hey</td><td>yo</td></tr>";
            while($row = mysql_fetch_array($res))
            {
                $students .= '<tr><td>' . $row['Firstname'] . '</td><td>' . $row['StudentKey'] .'</td>';
				$students .='<td><input type="text" id="grade"></input></td>';
				$students .='<td><input type="text" id="remark"></input></td></tr>';
            }
			$students .= "</tbody>";
            return $students;
		}
		
}
 
$opt = new SelectList();
?>